<?php
// +-------------------------------------------------------------------
// |
// +-------------------------------------------------------------------
// | Copyright (c) 2009-2016 All rights reserved.
// +-------------------------------------------------------------------
namespace Service\Api\V1;

class ArticleDetail
{
    public $login = false; //是否需要登录才能访问该接口
    public $title = "文章详情";
    public $group = '护眼科普';
    public $desc = "";

    public $input = [
        'article_id' => 'required;int;label=文章id;',
    ];

    public $output = [
        'id' => 'label=id;',
        'title' => 'label=标题;',
        'typeid_title' => 'label=分类标题;',
        'picture' => 'label=封面地址;',
        'create_time' => 'label=创建时间;',
        'content' => 'label=内容;',
        'view' => 'label=浏览数;',
    ];

    public function run($param, $uid)
    {
        $result = M('eyes_article')->where(['id' => $param['article_id']])->find();
        $result['picture'] = get_cover($result['picture'], 'url');

        if(strpos($result['content'],'<img src="/Uploads') !== false){
        //'包含'
        $result['content'] = str_replace('<img src="/Uploads','<img src="'.hostdomain.'/Uploads',$result['content']);
    }
        return $result;
    }
}
